package com.ycbj.android.app.manager;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;

import com.ycbj.android.app.R;

/**
 * Created by zed on 2017/5/3/0003.
 *
 * 中间fragment的管理工具
 */
public class MainUiManager {
    private static MainUiManager ourInstance = new MainUiManager();

    public static MainUiManager getInstance() {
        return ourInstance;
    }

    private MainUiManager() {
    }


    //TODO 这个用不用都是可以的，不用就在主界面实现切换fragment。
    //用来替换fragment
    public void replaceFragment(Fragment fragment, Activity context){
        FragmentManager fragmentManager = context.getFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        //TODO 这里替换的是main_fragment_container 主界面中的预留fragment
        // or fragment_base_child_container  BaseFargent中给子类预留的fragment
        transaction.replace(R.id.main_fragment_container, fragment);
        transaction.commit();
        //
    }
}
